<span class="tag_keyword">{{ helper:lang line='global:keyword' }} <strong>{{keyword}}</strong></span>
<?php //print_r($model)?>
{{ if model:shop_product }}
<div class="content">
<h3>{{ helper:lang line = 'global:module:shop' }}</h3>
<div class="outer_content">
	<div class="outer_product">
	<?php echo form_open('shop/cart/add/',array('id'=>'frm_product'));?>
	<?php echo form_hidden('pid', ''); ?>
    	<ul class="post-product">
		{{ model:shop_product }}
		<li class="product">
        	<div class="in-pro">
			<a class="pic" title="{{title}}" href="{{ url:site uri='shop/detail/{{slug}}' }}">
				<div class="zoom">
				<img width="<?php echo $shop_width ?>"  src="{{shop:product_image file = image thumbs='1' }}" />
				</div>
			</a>
            <p class="price">
            	{{ helper:number value = price }} <span>{{ helper:lang line = 'shop:currency' }}</span>
            </p>
            <span class="name_p">
            	<a title="{{title}}"  href="{{ url:site uri='shop/detail/{{slug}}' }}">{{ title }}</a>
            </span>
			<div class="hide box">
				<!--<div class="attribute">
					{{attributes}}
						<p class="item"><label>{{title}}:</label>{{value}}</p>
					{{/attributes}}
				</div>-->
				<?php echo form_submit('action', lang('shop:add_to_cart'),'pid="{{id}}" class="addtocart btn btn-primary white"'); ?>
			</div>
			<span class="pro_name">
				<a  href="{{ url:site uri='shop/detail/{{slug}}' }}" title="{{ title }}">{{ title }}</a>
			</span>
			</div>
        </li>
		{{ /model:shop_product }}
    </ul>
	<?php echo form_close();?>
	</div>
    
    <?php
		$data_page = $model['shop_product_page'];
		$total_page = $data_page['total_page'];
		if($total_page>1){
    ?>
    <div class="kun-pagination" page-size="<?php echo $data_page['size'] ?>">
    	<?php 
			
			for($i=0;$i<$total_page;$i++){
		 ?>
         	<a class="p_page" href="{{url:current}}?{{query_string}}#p=<?php echo ($i+1)?>"><?php echo ($i+1)?></a>
			<?php } ?>
    </div>
	<?php } ?>
</div>

<script type="text/javascript">
$('.addtocart').click(function(){
	$pid = $(this).attr('pid');
	$('#frm_product').find('input[name="pid"]').val($pid);
});
$ac = $('.menu li[rel="{{cat_id}}"]').addClass('active');
//$ac.parent().parent().addClass('active');
$ob = $('li.hasChild').find('.active');
if($ob.length>0){
	$('li.hasChild').addClass('active');
	
	
	$left_hover = '<div class="left_hover"></div>';
	$right_hover = '<div class="right_hover"></div>';
	$ob.after($right_hover);
	$ob.before($left_hover);
	$ob.addClass('main_hover');
	$ob.parent().show();
}
//alert('{{cat_id}}')




var li = $('.outer_product .product');
for($i = 0 ; $i < li.length; $i+=4){
	li.eq($i).addClass('first');
	li.eq($i+3).addClass('last');
}

//phan trang ajax
//frm_product

var h = location.hash;
if(h)
	product_get();
$(window).bind('hashchange', function() {
	product_get();
});

var products;
function product_get(){
	$h = location.hash;
	 $t = $h.substr(1,1);
	 //phan trang san pham
	 if($t == "p"){
	 	$index = parseInt($h.substr(3) - 1);
		$page_size = parseInt('{{model:shop_product_page:size}}');
		$kw = '{{model:keyword}}';
		if(products != null){
			products.abort();
		}
		products = $.ajax({
			url:'{{url:site uri="shop/product/search"}}',
			data:{keyword:$kw,index:$index,size:$page_size},
			type:'get',
			//dataType:'json',
			success: function(data){
				$('.p_page.active').removeClass('active');
				$('.p_page').eq($index).addClass('active');
				$('form#frm_product').html('').html(data);
				add_cart();
			}
		});
	 }
}
</script>
</div>
{{endif}}

{{ if model:shop_categories }}
<div class="clr"></div>
<div class="content">
<style>
 .list-cat .item{
	 margin:15px 0;
 }
 .list-cat a{
	 color:#333;
	 font-weight:bold;
	 font-size:14px;
 }
</style>
<h3>{{ helper:lang line='global:categories' }}</h3>
<div class="list-cat">
	{{ model:shop_categories }}
	<div class="item">
    	<a href="{{ url:site uri='shop/categories/{{slug}}' }}">{{ title }}</a>
    </div>
    {{ /model:shop_categories }}
</div>
</div>
{{endif}}